package com.cwd.arm.infrastructure.dao.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
import com.cwd.arm.common.util.DateUtil;
import com.cwd.arm.infrastructure.dao.ConfirmIncomeDao;
import com.cwd.arm.infrastructure.dao.base.DaoImpl;
import com.cwd.arm.infrastructure.mapper.ConfirmIncomeMapper;
import com.cwd.arm.infrastructure.po.ConfirmIncomePo;
import com.cwd.arm.infrastructure.query.ConfirmIncomeDaoQuery;
import org.springframework.stereotype.Service;

import java.util.List;

/**
* Description:确认收入
* Created on 2021年11月16日
* @author  yan
*/
@Service
public class ConfirmIncomeDaoImpl extends DaoImpl<ConfirmIncomeMapper, ConfirmIncomePo> implements ConfirmIncomeDao {

    @Override
    public List<ConfirmIncomePo> selectByQuery(ConfirmIncomeDaoQuery daoQuery) {
        QueryWrapper queryWrapper = new QueryWrapper();
        queryWrapper.eq(ObjectUtils.isNotEmpty(daoQuery.getHasReceipt()),"has_receipt",daoQuery.getHasReceipt());
        queryWrapper.apply(ObjectUtils.isNotEmpty(daoQuery.getNow()),"DATE_FORMAT(confirm_date,'%Y-%m-%d') <= {0}", DateUtil.dateToDateStr(daoQuery.getNow()));
        queryWrapper.eq(ObjectUtils.isNotEmpty(daoQuery.getProjectId()),"project_id",daoQuery.getProjectId());
        return list(queryWrapper);
    }
}
